
/*******************************************************************************
 * The code below this comment is integral part of the project "Jelliphy".
 * 
 * "Jelliphy" is a project created by: 
 * Dispage - Patrizio Gelosi
 * Via A. De Gasperi 91 
 * P. Potenza Picena (MC) - Italy
 * 
 * (Hereby referred to as "DISPAGE")
 * 
 * Copyright (c) 2011 DISPAGE.
 * 
 * @Released on: 02-06-2011
 * @Version: 1.0.00
 * @Build: 1109
 * @Site: http://www.dispage.com
 * @Contacts: http://www.dispage.com/contacts
 * 
 * The contents of this file are released under the GNU General Public License
 * version 3 as published by the Free Software Foundation that can be found at
 * the address "http://opensource.org/licenses/gpl-3.0.html". If the license
 * cannot be found, write to the Free Software Foundation, Inc., 51 Franklin
 * Street, Fifth Floor, Boston, MA 02110-1301 USA.
 * 
 * You may not use the present file except in compliance with the License.
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the License
 * for the specific language governing rights and limitations under the
 * License.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * Dispage" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by Dispage".
 * 
 ******************************************************************************/

var MGBP = new function () {

	var that = this,


		buttonMouseDown = function () {

			var $this = JlQ(this);

			if ($this.hasClass('mg-button-disabled')) return;

			$this.addClass('mg-button-down');
		};

	
	that.sessionID = null;


	that.initBasicPanels = function () {
		
		JlQ('.mg-panel:not(.mg-panel-quickedit)').cssImportant('position', 'fixed');
	};

	that.hoverButtons = function (ev) {

		var $this = JlQ(this);

		if ($this.hasClass('mg-button-disabled')) return;

		if (ev.type == 'mouseenter')	{
			$this.attr("style", "background-color:"+($this.hasClass('mg-button-down') && !$this.hasClass('mg-quick-icons-container') ? "#D7D4DD" : "#B4B3D1")+" !important;");
		}
		else {
			$this.removeAttr('style');
		}
	};

	that.getGeneralLink = function () {

		return "javascript:if(document.location.href.search(/[?&]" + MGAccessKey + "(?:[&=]|$)/)==-1)document.location.href=document.location.href.replace(/#|$/,(document.location.href.indexOf('?')==-1?'?':'&')+'" + MGAccessKey + "$&');";
	}

	that.initBasicButtons = function () {

		JlQ('.mg-button').hover(MGBP.hoverButtons);

		JlQ('.mg-button:not(.mg-button-radio)')
			.mousedown(buttonMouseDown)
			.mouseup(function () {JlQ(this).removeClass('mg-button-down')});

		JlQ('#mg-login-sec > a').attr('href', that.getGeneralLink());
	};

};